package com.psp.park.persist.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.psp.park.model.ParkUserBean;
import com.psp.park.model.UserLoginLogBean;
import com.psp.park.model.UserUpdateLogBean;
import com.psp.park.persist.dao.UserDao;

@Repository
public class UserImpl extends BaseImpl implements UserDao {
	final String NAME_SPACE = NAME_SPACE_HEADER + ".ParkUserMapper";

	@Override
	public ParkUserBean selectOneByAccount(String account) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneByAccount", account);
	}

	@Override
	public int updateLoginTime(String buid) {
		return sqlSessionTemplate.update(NAME_SPACE + ".updateLoginTime", buid);
	}

	@Override
	public ParkUserBean selectOne(String uid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneByUid", uid);
	}

	@Override
	public int updatePwd(ParkUserBean user) {
		Map<String, Object> params = new HashMap<>();
		params.put("uid", user.getPuid());
		params.put("password", user.getPassword());
		return sqlSessionTemplate.update(NAME_SPACE + ".updatePwd", params);
	}

	@Override
	public int insertLoginLog(UserLoginLogBean loginLog) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertLoginLog", loginLog);
	}

	@Override
	public int insertUpdateLog(UserUpdateLogBean updateLog) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertUpdateLog", updateLog);
	}

}
